import pymysql

db = pymysql.connect(
    host='localhost',
    port=3306,
    database='jiangsu',
    user='root',
    password='root',
    charset='utf8'
)

cursor = db.cursor()
sql = ("insert into student (s_id, s_name, s_birth, s_sex) "
       "values ('11', 'hhh', '1990-01-20', '女'),"
       "('12', 'whh', '1990-01-20', '女')")
cursor.execute(sql)
# db.rollback()  # 回滚

cursor = db.cursor()
sql = ("insert into student (s_id, s_name, s_birth, s_sex) "
       "values ('13', 'hhh', '1990-01-20', '女'),"
       "('14', 'whh', '1990-01-20', '女')")
cursor.execute(sql)
db.commit()  # 提交事务

# 关闭链接
cursor.close()
db.close()
